# -*- coding: utf-8 -*-
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.model_selection import cross_val_score
import numpy as np
from matplotlib import pyplot as plt
from sklearn.naive_bayes import GaussianNB
from sklearn.metrics import classification_report
from sklearn.svm import SVC

iris = load_iris()
x = iris.data
y = iris.target
print(x.shape)

#划分训练集与验证集
X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.5, random_state=0)

gnb = GaussianNB()

y_predict2 = gnb.fit(X_train,y_train).predict(X_test)

print(classification_report(y_test, y_predict2))



clf = SVC(decision_function_shape='ovo')


clf.fit(X_train, y_train)
print(clf.support_vectors_)


y_predict = clf.predict(X_test)
#模型的验证报告
print(classification_report(y_test, y_predict))




linear_svc = SVC(kernel="linear")
#linear_svc.fit(X_train, y_train)
rbf_svc = SVC(kernel="rbf")
#rbf_svc.fit(X_train, y_train)

print('cross val')
print(cross_val_score(linear_svc, x, y, cv=5))
print(cross_val_score(rbf_svc, x, y, cv=5))
